package com.totoro.mapstruct.mapstruct_field_mapping;

import com.totoro.mapstruct.mapstruct_field_mapping.bean.Customer;
import com.totoro.mapstruct.mapstruct_field_mapping.bean.CustomerDto;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author Filip Hrisafov
 */
@Mapper(uses = { OrderItemMapper.class })
public interface CustomerMapper {

    CustomerMapper MAPPER = Mappers.getMapper( CustomerMapper.class );

    @Mappings({
            @Mapping(source = "orders", target = "orderItems"),
            @Mapping(source = "customerName", target = "name")
    })
    Customer toCustomer(CustomerDto customerDto);

//    @InheritInverseConfiguration
    CustomerDto fromCustomer(Customer customer);
}